package com.ccq.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
public class CaheRedisController {
	@Autowired
	private RedisTemplate<Object, Object> redisTemplate;
	@RequestMapping("/redis")
	public String testRedis() {
		List<String> list = new ArrayList<>();
		list.add("111");
		list.add("222");
		list.add("333");
		redisTemplate.opsForList().leftPushAll("list2", list);
		// redisTemplate.opsForValue().set("xxx", "xxx");
		// redisTemplate.opsForValue().set("user", new User("name", "age",
		// "1"));
		return "redis 测试成功";
	}

	@RequestMapping("/getRedis")
	public String getRedis() {

		String object = (String) redisTemplate.opsForValue().get("list");
		return object;
	}
}
